<#include "/WEB-INF/template/common/macro/base.ftl"/>
<#include "/WEB-INF/template/common/macro/libs.ftl"/>
<#include "/WEB-INF/template/common/layout/l_admin.ftl"/>
<@adminLayout>
    <@breadcrumb view=breadcrumbView/>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box light-grey">
            <div class="portlet-title">
                <div class="caption"><i class="fa fa-globe"></i>${breadcrumbView.getCurmenu().name!}</div>
                <div class="actions">
                    <a id="list_add" class="btn blue" data-toggle="modal" href="${CONTEXT_PATH}/banners/add">
                        <i class="fa fa-plus-circle"></i>
                        添加
                    </a>
                </div>
            </div>
            <div class="portlet-body">
                <div class="table-toolbar">
                </div>
                <table class="table table-striped table-bordered table-hover" style="width:100%"
                       id="sample_1">
                    <thead>
                    <tr>
                        <th width="5%"></th>
                        <th style="display:none"></th>
                        <th width="15%">标题</th>
                        <th width="25%">描述</th>
                        <th width="10%">是否有效</th>
                        <th width="5%">发布日期</th>
                        <th width="10%">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        <#list list as item>
                        <tr>
                            <td><span class="row-details row-details-close"></span></td>
                            <td style="display: none">${item.text}</td>
                            <td>${item.title}</td>
                            <td>${item.summary}</td>
                            <td>${(item.liveflag==1)?string('是','否')}</td>
                            <td>${(item.createtime)?string("yyyy-MM-dd HH:mm:ss")}</td>
                            <td>
                                <a href="${CONTEXT_PATH}/banners/edit/${item.uuid}"
                                   class="btn btn-primary btn-xs">
                                    <i class="fa fa-pencil update"></i>
                                </a>
                                <a href="javascript:;" onclick="deletebyid(this,'${item.uuid}')"
                                   class="btn btn-danger btn-xs">
                                    <i class="fa fa-minus-circle"></i>
                                </a>
                            </td>
                        </tr>
                        </#list>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
    <!--model begin-->
    <@Modal_SystemOpera/>
    <!--model end-->
</div>
    <@script>
        <@libs_datatables/>
    <script type="text/javascript">

        jQuery(document).ready(function () {
            /* 1.初始化table */
            var oTable = $('#sample_1').dataTable({
                "sPaginationType": "bootstrap",
                "aLengthMenu": [[5, 10, 20, -1], [5, 10, 20, "所有"]],
                "iDisplayLength": 5
            });
            /*搜索框样式*/
            $("#sample_1_filter input[type='text']").addClass("form-control input-small");
            /* +单击事件*/
            $('#sample_1').on('click', ' tbody td .row-details', function () {
                var nTr = $(this).parents('tr')[0];
                if (oTable.fnIsOpen(nTr)) {
                    /* This row is already open - close it */
                    $(this).addClass("row-details-close").removeClass("row-details-open");
                    oTable.fnClose(nTr);
                } else {
                    /* Open this row */
                    $(this).addClass("row-details-open").removeClass("row-details-close");
                    oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details');
                }
            });
        });
        function deletebyid(obj, id) {
            var cfg = $.extend(CONST_ACTION.DELETE, {
                actiondom: $(obj),
                actionurl: "${CONTEXT_PATH}/banners/delete/" + id
            })
            SystemConfirm(cfg)
        }

        /* Formatting function for row details */
        function fnFormatDetails(oTable, nTr) {
            var aData = oTable.fnGetData(nTr);
            var sOut = [];
            sOut.push("<div style='margin: 5px;'>");
            sOut.push(aData[1]);
            sOut.push("</div>");
            return sOut.join("");
        }
    </script>
    </@script>
</@adminLayout>
